<!doctype html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>虚假磁链生成器</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link rel="stylesheet" type="text/css" href="css/normalize.css" />
    <link rel="stylesheet" type="text/css" href="css/default.css">
    <script>
        var _hmt = _hmt || [];
        (function () {
            var hm = document.createElement("script");
            hm.src = "//hm.baidu.com/hm.js?7d6ef64c441242cb7dd0f52a0cd5e552";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();
    </script>

</head>

<body style="width:100%;height:100%;margin:0;">
    <div class="htmleaf-container">
        <header class="htmleaf-header">
            <h1>虚假磁链生成器 <span>妈蛋这是黑车！</span></h1>
        </header>
        <div class="related">
            <div>
                <p>自定义磁链前缀：<input type="text" id="head" value="magnet:?xt=urn:btih:" /></p>
                <p>需要的磁链数量：<input type="text" id="sum" value="10"></p>
                <p><button onclick="getResult()">点击生成</button></p>
            </div>
            <textarea style="border:0px;background:none;color:white;" cols=80 rows=10 id="btresult" readonly="true">

            </textarea>


            <br><br><br><a href="https://www.chenxublog.com/" target="_blank">by 晨旭</a>
            <a href="update.html" target="_blank">更新日志</a>
            <a href="https://github.com/chenxuuu/fake-magnet" target="_blank">GitHub源码</a>
        </div>
    </div>
    <script src="dist/jquery.min.js"></script>
    <script src="dist/jquery-starfield.js"></script>
    <script>
        $('.htmleaf-container').starfield({
            starDensity: 2.0,
            mouseScale: 0.5,
            seedMovement: true
        });

        function random(length,characters) {
            var result = '';
            var charactersLength = characters.length;
            for (var i = 0; i < length; i++) {
                result += characters.charAt(Math.floor(Math.random() * charactersLength));
            }
            return result;
        }

        function randomStr(len) {
            return random(len,'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789');
        }
        function randomHex(len) {
            return random(len,'ABCDEF0123456789');
        }
        function randomL(len) {
            return random(len,'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
        }
        function randomS(len) {
            return random(len,'abcdefghijklmnopqrstuvwxyz');
        }
        function randomSum(len) {
            return random(len,'0123456789');
        }

        function getResult() {
            var head = $('#head').val();
            var sum = Number($('#sum').val());
            if (sum == 0)
                sum = 10;
            $('#btresult').text('');
            $('#btresult').append(sum + "个虚假磁链生成完毕！（请勿复制这一行！）\r\n");
            for (var i = 0; i < sum; i++) {
                var ran = Math.random();
                if(ran < 0.1){
                    $('#btresult').append(head + randomStr(40) + '&dn=');
                    var l = Math.random() * 10;
                    for(var j=0;j<l;j++)
                        $('#btresult').append('%'+randomHex(2));
                    $('#btresult').append("\r\n");
                }else if(ran < 0.2){
                    $('#btresult').append(head + randomStr(40) + "&dn=" + randomL(3) + "-" + randomSum(3) + "\r\n");
                }else if(ran < 0.3){
                    $('#btresult').append(head + randomStr(40) + "&dn=" + randomS(3) + "-" + randomSum(3) + "\r\n");
                }else{
                    $('#btresult').append(head + randomStr(40) + "\r\n");
                }
            }
        }
    </script>
</body>

</html>
